package org.catspaw.cherubim.persistence.spring.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.commons.dbutils.RowProcessor;
import org.catspaw.cherubim.persistence.jdbc.dbutils.RowProcessorFactory;
import org.springframework.jdbc.core.RowMapper;

public class NameTrimmedBeanRowMapper implements RowMapper {

	private Class		beanClass;
	private RowProcessor rowProcessor = RowProcessorFactory
											  .getNameTrimmedBeanRowProcessor();

	public NameTrimmedBeanRowMapper(Class beanClass) {
		this.beanClass = beanClass;
	}

	public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
		return rowProcessor.toBean(rs, beanClass);
	}
}
